package cn.kai.process.flow.core;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * 流程链
 Author: cKnight
 Date: 2025/1/23
 */
public class FlowChain {
    /** 链名称 */
    @Getter
    private String name;
    /** 链所有的节点 */
    @Setter
    private List<Node> nodes = new ArrayList<>();

    public FlowChain(String name){
        this.name = name;
    }

    public FlowChain(List<Node> nodes){
        this.nodes = nodes;
    }

    public void addNode(Node node){
        this.nodes.add(node);
    }

    /** 执行当前链 */
    public void execute(NodeContext context){
        for (Node node : nodes) {
            node.exe(context);
        }
    }
}
